/**
 */
package ram_av.provider;


import java.util.Collection;
import java.util.List;

import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.ResourceLocator;

import org.eclipse.emf.ecore.EStructuralFeature;

import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
import org.eclipse.emf.edit.provider.ViewerNotification;

import ram_av.Message;
import ram_av.MessageSort;
import ram_av.Ram_avFactory;
import ram_av.Ram_avPackage;

/**
 * This is the item provider adapter for a {@link ram_av.Message} object.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class MessageItemProvider
  extends ItemProviderAdapter
  implements
    IEditingDomainItemProvider,
    IStructuredItemContentProvider,
    ITreeItemContentProvider,
    IItemLabelProvider,
    IItemPropertySource
{
  /**
   * This constructs an instance from a factory and a notifier.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public MessageItemProvider(AdapterFactory adapterFactory)
  {
    super(adapterFactory);
  }

  /**
   * This returns the property descriptors for the adapted class.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object)
  {
    if (itemPropertyDescriptors == null)
    {
      super.getPropertyDescriptors(object);

      addSendEventPropertyDescriptor(object);
      addReceiveEventPropertyDescriptor(object);
      addSignaturePropertyDescriptor(object);
      addAssignToPropertyDescriptor(object);
      addMessageSortPropertyDescriptor(object);
      addSelfMessagePropertyDescriptor(object);
    }
    return itemPropertyDescriptors;
  }

  /**
   * This adds a property descriptor for the Send Event feature.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected void addSendEventPropertyDescriptor(Object object)
  {
    itemPropertyDescriptors.add
      (createItemPropertyDescriptor
        (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
         getResourceLocator(),
         getString("_UI_Message_sendEvent_feature"),
         getString("_UI_PropertyDescriptor_description", "_UI_Message_sendEvent_feature", "_UI_Message_type"),
         Ram_avPackage.Literals.MESSAGE__SEND_EVENT,
         true,
         false,
         true,
         null,
         null,
         null));
  }

  /**
   * This adds a property descriptor for the Receive Event feature.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected void addReceiveEventPropertyDescriptor(Object object)
  {
    itemPropertyDescriptors.add
      (createItemPropertyDescriptor
        (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
         getResourceLocator(),
         getString("_UI_Message_receiveEvent_feature"),
         getString("_UI_PropertyDescriptor_description", "_UI_Message_receiveEvent_feature", "_UI_Message_type"),
         Ram_avPackage.Literals.MESSAGE__RECEIVE_EVENT,
         true,
         false,
         true,
         null,
         null,
         null));
  }

  /**
   * This adds a property descriptor for the Signature feature.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected void addSignaturePropertyDescriptor(Object object)
  {
    itemPropertyDescriptors.add
      (createItemPropertyDescriptor
        (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
         getResourceLocator(),
         getString("_UI_Message_signature_feature"),
         getString("_UI_PropertyDescriptor_description", "_UI_Message_signature_feature", "_UI_Message_type"),
         Ram_avPackage.Literals.MESSAGE__SIGNATURE,
         true,
         false,
         true,
         null,
         null,
         null));
  }

  /**
   * This adds a property descriptor for the Assign To feature.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected void addAssignToPropertyDescriptor(Object object)
  {
    itemPropertyDescriptors.add
      (createItemPropertyDescriptor
        (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
         getResourceLocator(),
         getString("_UI_Message_assignTo_feature"),
         getString("_UI_PropertyDescriptor_description", "_UI_Message_assignTo_feature", "_UI_Message_type"),
         Ram_avPackage.Literals.MESSAGE__ASSIGN_TO,
         true,
         false,
         true,
         null,
         null,
         null));
  }

  /**
   * This adds a property descriptor for the Message Sort feature.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected void addMessageSortPropertyDescriptor(Object object)
  {
    itemPropertyDescriptors.add
      (createItemPropertyDescriptor
        (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
         getResourceLocator(),
         getString("_UI_Message_messageSort_feature"),
         getString("_UI_PropertyDescriptor_description", "_UI_Message_messageSort_feature", "_UI_Message_type"),
         Ram_avPackage.Literals.MESSAGE__MESSAGE_SORT,
         true,
         false,
         false,
         ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
         null,
         null));
  }

  /**
   * This adds a property descriptor for the Self Message feature.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected void addSelfMessagePropertyDescriptor(Object object)
  {
    itemPropertyDescriptors.add
      (createItemPropertyDescriptor
        (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
         getResourceLocator(),
         getString("_UI_Message_selfMessage_feature"),
         getString("_UI_PropertyDescriptor_description", "_UI_Message_selfMessage_feature", "_UI_Message_type"),
         Ram_avPackage.Literals.MESSAGE__SELF_MESSAGE,
         false,
         false,
         false,
         ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE,
         null,
         null));
  }

  /**
   * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
   * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
   * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object)
  {
    if (childrenFeatures == null)
    {
      super.getChildrenFeatures(object);
      childrenFeatures.add(Ram_avPackage.Literals.MESSAGE__ARGUMENTS);
      childrenFeatures.add(Ram_avPackage.Literals.MESSAGE__RETURNS);
    }
    return childrenFeatures;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EStructuralFeature getChildFeature(Object object, Object child)
  {
    // Check the type of the specified child object and return the proper feature to use for
    // adding (see {@link AddCommand}) it as a child.

    return super.getChildFeature(object, child);
  }

  /**
   * This returns Message.gif.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object getImage(Object object)
  {
    return overlayImage(object, getResourceLocator().getImage("full/obj16/Message"));
  }

  /**
   * This returns the label text for the adapted class.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String getText(Object object)
  {
    MessageSort labelValue = ((Message)object).getMessageSort();
    String label = labelValue == null ? null : labelValue.toString();
    return label == null || label.length() == 0 ?
      getString("_UI_Message_type") :
      getString("_UI_Message_type") + " " + label;
  }

  /**
   * This handles model notifications by calling {@link #updateChildren} to update any cached
   * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void notifyChanged(Notification notification)
  {
    updateChildren(notification);

    switch (notification.getFeatureID(Message.class))
    {
      case Ram_avPackage.MESSAGE__MESSAGE_SORT:
      case Ram_avPackage.MESSAGE__SELF_MESSAGE:
        fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
        return;
      case Ram_avPackage.MESSAGE__ARGUMENTS:
      case Ram_avPackage.MESSAGE__RETURNS:
        fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
        return;
    }
    super.notifyChanged(notification);
  }

  /**
   * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
   * that can be created under this object.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object)
  {
    super.collectNewChildDescriptors(newChildDescriptors, object);

    newChildDescriptors.add
      (createChildParameter
        (Ram_avPackage.Literals.MESSAGE__ARGUMENTS,
         Ram_avFactory.eINSTANCE.createParameterValueMapping()));

    newChildDescriptors.add
      (createChildParameter
        (Ram_avPackage.Literals.MESSAGE__RETURNS,
         Ram_avFactory.eINSTANCE.createValueSpecification()));

    newChildDescriptors.add
      (createChildParameter
        (Ram_avPackage.Literals.MESSAGE__RETURNS,
         Ram_avFactory.eINSTANCE.createStructuralFeatureValue()));

    newChildDescriptors.add
      (createChildParameter
        (Ram_avPackage.Literals.MESSAGE__RETURNS,
         Ram_avFactory.eINSTANCE.createParameterValue()));

    newChildDescriptors.add
      (createChildParameter
        (Ram_avPackage.Literals.MESSAGE__RETURNS,
         Ram_avFactory.eINSTANCE.createOpaqueExpression()));

    newChildDescriptors.add
      (createChildParameter
        (Ram_avPackage.Literals.MESSAGE__RETURNS,
         Ram_avFactory.eINSTANCE.createLiteralSpecification()));

    newChildDescriptors.add
      (createChildParameter
        (Ram_avPackage.Literals.MESSAGE__RETURNS,
         Ram_avFactory.eINSTANCE.createLiteralString()));

    newChildDescriptors.add
      (createChildParameter
        (Ram_avPackage.Literals.MESSAGE__RETURNS,
         Ram_avFactory.eINSTANCE.createLiteralInteger()));

    newChildDescriptors.add
      (createChildParameter
        (Ram_avPackage.Literals.MESSAGE__RETURNS,
         Ram_avFactory.eINSTANCE.createLiteralBoolean()));
  }

  /**
   * Return the resource locator for this item provider's resources.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public ResourceLocator getResourceLocator()
  {
    return RAM_adviceEditPlugin.INSTANCE;
  }

}
